/**************************************************************************************
* Component of simpleRTJ regression tests.
**************************************************************************************
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL RTJ COMPUTING BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Created by:
*       RTJ Computing
**************************************************************************************/
public class TestControl
{
    public static void test() throws Exception
    {
        int t = 0;

        //for
        for (int i = 0; i < 10; i++)
        {
            t++;
        }
        if (t != 10) throw new Exception("CT1");


        t = 0;
        for (int i = 0; i < 10; i++,t++);
        if (t != 10) throw new Exception("CT2");

        //while
        t = 0;
        while (t < 10 ) { t++;}
        if (t != 10) throw new Exception("CT3");

        //do while
        t = 0;
        do
        {
            t++;
        } while (t < 10);
        if (t != 10) throw new Exception("CT4");


        //switch
        t = 0;
        for (int i = 0; i < 10; i++)
        {
            switch (i % 3)
            {
              case 0:
                  t++;
              case 1:
                  t++;
                  break;
              default:
            }
        }
        if (t != 11) throw new Exception("CT5");

        // continue
        t = 0;
        for (int i = 0; i < 10 ; i++)
        {
            if (i < 5) continue;
            t++;
        }
        if (t != 5) throw new Exception("CT6");

        // break
        t = 0;
        for (int i = 0; i < 10 ; i++)
        {
            if (i == 6) break;
            t++;
        }
        if (t != 6) throw new Exception("CT7");


        //nested
        t = 0;
        for (int i = 0; i < 5 ; i++)
        {
            for (int j = 0; j < 5 ; j++)
            {
                t++;
            }
        }
        if (t != 25) throw new Exception("CT8");


        //continue with label
        t = 0;
        loop1: for (int i = 0; i < 5 ; i++)
        {
            for (int j = 0; j < 5 ; j++)
            {
                if (j > 2) continue loop1;
                t++;
            }
        }
        if (t != 15) throw new Exception("CT9");

        t = 0;
        //break with label (same as class)
        TestControl: for (int i = 0; i < 5 ; i++)
        {
            for (int j = 0; j < 5 ; j++)
            {
                if (j > 2) break TestControl;
                t++;
            }
        }
        if (t != 3) throw new Exception("CT10");
     }
}
